package com.easybuilder.common.utils;

import com.easybuilder.core.authorization.entity.SysGiteeUser;
import com.easybuilder.core.rbac.entity.SysUser;
import org.springframework.stereotype.Component;

@Component
public class UserUtil { // 用户工具类

    /** 存储当前请求的用户信息，方便后续在其他类中获取请求用户信息 */
    private static final ThreadLocal<SysUser> USERS = new ThreadLocal<>();

    /**存放码云登陆用户请求信息 */
    private static final ThreadLocal<SysGiteeUser> GITEE_USERS = new ThreadLocal<>();

    /** 设置用户信息 */
    public static void setUser(SysUser sysUser) {
        USERS.set(sysUser);
    }

    /** 获取用户信息 */
    public static SysUser getUser() {
        return USERS.get();
    }

    /** 清除用户信息 */
    public static void clearUser() {
        USERS.remove();
    }
}
